package org.example.basic.day06;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 清倌
 */
public class DemoMap集合 {
    public static void main(String[] args) {
        Map<String, List<Book>> map = new HashMap<>();
       List<Book> list = new ArrayList<>();
       list.add(new Book("java", 100));
       list.add(new Book("python", 200));
       list.add(new Book("c++", 300));
       map.put("编程类", list);
       //map遍历
       for (Map.Entry<String, List<Book>> entry : map.entrySet()){
           System.out.println(entry.getKey() + ":" + entry.getValue());
       }

       Tool<String> tool = new Tool<>();
       tool.show("hello world");
       Tool<Book> tool1 = new Tool<>();
       tool1.show(new Book("java", 100));

    }
}
/**
 * 泛型类
 */
@Data
class Tool<R>{
    private R r;
    public void show(R r){
        System.out.println( r);
    }
}

/**
 * 实体类
 */
@Data
@AllArgsConstructor
class Book{
    private String name;
    private Integer price;
}
